package com.neuedu.his.dao;

import com.neuedu.his.entity.CheckApply;
import com.neuedu.his.entity.CheckApply;
import com.neuedu.his.framework.BaseDao;
import com.neuedu.util.JDBCUtil;

import java.util.List;

/**
 * 项目：      his
 * 类名:       CheckApplyDao
 * 创建时间：  2020/12/23  8:43
 * 描述 :     用户数据访问层
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
public class CheckApplyDao implements BaseDao<CheckApply> {


    @Override
    public List<CheckApply> selectList(String sql, Object... args) {
        return JDBCUtil.executeQuery(sql, CheckApply.class, args);
    }

    @Override
    public CheckApply selectById(Integer id) {
        String sql = " select * from check_apply where id = ?";
        return JDBCUtil.getOne(sql, CheckApply.class, id);
    }

    @Override
    public boolean update(CheckApply checkApply) {

       String sql  = " UPDATE   check_apply SET   register_id = ?,item_id = ?,   item_name = ?,status = ?,   fee = ? WHERE id = ? ";

        return JDBCUtil.executeUpdate(sql,
                checkApply.getRegisterId(),
                checkApply.getItemId(),
                checkApply.getItemName(),
                checkApply.getStatus(),
                checkApply.getFee()
        );
    }



    /**
     * 逻辑删除，没有真正删除数据
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(Integer id) {

        String sql = " update  check_apply set active = 0 where id  = ? ";

        return JDBCUtil.executeUpdate(sql,id);
    }

    @Override
    public boolean batchDel(String sql, Object... parm) {
        return false;
    }

    @Override
    public boolean insert(CheckApply checkApply) {
        String sql = " INSERT INTO check_apply(   register_id,item_id,   item_name,status,   fee )  VALUES ( ?,?, ?,?, ? )  ";
        return JDBCUtil.executeUpdate(sql,
                checkApply.getRegisterId(),
                checkApply.getItemId(),
                checkApply.getItemName(),
                checkApply.getStatus(),
                checkApply.getFee());
    }


}
